#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <dirent.h>
#define BUFFER_SIZE 32
int main()
{
    const char *name = "/home/admin/257class/BasiC/operating-system/FileIO/testFile-DIR/music";
    
    char buffer[BUFFER_SIZE] = { 0 };
    getcwd(buffer, BUFFER_SIZE-1);
    printf("buffer:%s\n", buffer);
     
    DIR *dir = opendir(name);
    if(dir == NULL)
    {
        perror("opendir error");
        return -1;
    }
    struct dirent *musicdir = NULL;
    while((musicdir = readdir(dir)) != NULL)
    {
        if(musicdir->d_type != DT_DIR)//取出.和..
        {
            printf("d_name:%s\n", musicdir->d_name); 
        }     
    }

    /* 关闭文件夹 */
    closedir(dir);
    return 0;
}























